﻿@using Bonobo.Git.Server.Extensions
@model RepositoryTreeModel
@{
    Layout = "~/Views/Repository/_RepositoryLayout.cshtml";
    ViewBag.Title = Resources.Repository_Tree_Title;
}
@if (Model != null)
{
    <div class="uniForm">
        <fieldset class="inlineLabels detail">
            <h3>@Model.Name</h3>
        </fieldset>
    </div>
    <div class="repositoryContent">
        @Html.Partial("_BranchSwitcher")
        @Html.Partial("_AddressBar")
        @{
            var grid = new WebGrid(source: Model.Files, rowsPerPage: 100);
            <div class="w-grid">
                @grid.GetHtml(
                    tableStyle: "grid",
                    headerStyle: "head",
                    alternatingRowStyle: "even",
                    columns: grid.Columns(
                     grid.Column("Name", header: typeof(RepositoryTreeDetailModel).GetDisplayValue("Name"), format: (item) => @Html.ActionLink((string)item.Name, item.IsTree ? "Tree" : "Blob", new { name = item.TreeName, path = item.Path }, new { @class = item.IsTree ? "directory" : item.IsImage ? "image" : "file" })),
                        grid.Column("CommitMessage", header: typeof(RepositoryTreeDetailModel).GetDisplayValue("CommitMessage")),
                        grid.Column("CommitDate", header: typeof(RepositoryTreeDetailModel).GetDisplayValue("CommitDate"), format: item => ((DateTime)item.CommitDate).ToString(Resources.DateTimeFormat)),
                        grid.Column("Author", header: typeof(RepositoryTreeDetailModel).GetDisplayValue("Author"))
                    )
                )
            </div>
        }
    </div>
}
